import { _decorator, Component, Node, AudioSource, Label } from 'cc';
const { ccclass, property } = _decorator;

@ccclass('setAudio')
export class setAudio extends Component {
    @property(Node)
    myChildLebel:Node = null;

    @property(AudioSource)
    bgmAudio: AudioSource = null;
    audioBoolean;
    start() {
        this.bgmAudio.play();
        this.audioBoolean = true;
    }
    AudioBool() {
        this.audioBoolean = !this.audioBoolean;
        this.startAudio();
    }
    startAudio() {
        let label = this.myChildLebel.getComponent(Label)
        if (this.audioBoolean) {
            label.string = '音乐开'
            this.bgmAudio.play();
        } else {
            label.string = '音乐关'

            this.bgmAudio.pause();
        }
    }
    

    update(deltaTime: number) {

    }
}

